<template>
  <div class="container">
    <!-- <happy-scroll size="5" resize> -->
    <!-- <el-menu :default-active="defaultActive" mode="horizontal" router @select="menuSelect"  >
            <el-menu-item
              :index="item.modulePathUrl"
              v-for="item in list"
              :key="item.moduleId"
            >
              <span slot="title">{{ item.moduleName }}</span>
            </el-menu-item>
          </el-menu> -->

    <!-- </happy-scroll> -->
    <el-card shadow="always" class="analysis">
      <el-tabs
        v-model="activeName"
        @tab-click="
          (e) => {
            $router.push(e.name);
          }
        "
      >
        <el-tab-pane
          :label="item.moduleName"
          :index="item.modulePathUrl"
          v-for="item in list"
          :key="item.moduleId"
          :name="item.modulePathUrl"
        ></el-tab-pane>
        <!-- <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
    <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
    <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane> -->
      </el-tabs>

      <router-view></router-view>
    </el-card>
  </div>
  <!-- <el-container>
     <div class="Jump">
        <el-button
        @click="Jump"
        style="margin-right: 20px"
        icon="el-icon-back"
        type="primary"
        >返回上一页</el-button
      >
   </div> -->

  <!-- <el-container class="content">
      <el-aside width="200px" :style="{ height: height }">
        <happy-scroll size="5" resize>
         
        </happy-scroll>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container> -->
  <!-- </el-container> -->
</template>
<script>
import { HappyScroll } from "vue-happy-scroll";
//自定义组件名
// Vue.component('happy-scroll', HappyScroll)
// 引入css
import "vue-happy-scroll/docs/happy-scroll.css";
import {
  CompanyMainPageInfo,
  findByBodyIndustry,
} from "@/api/modules/enterprise";
export default {
  // props:[],
  // 页面加载
  created() {
    this.getCompanyMainPageInfo();
    this.height = document.body.clientHeight - 130 + "px";
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {
    sessionStorage.removeItem("menuSelect");
  },
  //实例销毁后
  destroyed() {},
  data() {
    return {
      data: {},
      list: [],
      height: "200px",
      activeName: "/enterprise/responsibility",
    };
  },
  // 方法
  methods: {
    // 改业态
    getCompanyMainPageInfo() {
      CompanyMainPageInfo({
        params: {
          id: sessionStorage.getItem("interpretation"),
        },
      }).then((res) => {
        this.data = res.data;
        // let bodyindustryremarks = "";
        // if (res.data.bodyindustryremarks.includes("托育（托幼）")) {
        //   bodyindustryremarks = "幼托机构食堂";
        // } else if (
        //   // res.data.bodyindustryremarks.includes("学校") ||
        //   // res.data.bodyindustryremarks == "高等教育机构" ||
        //   // res.data.bodyindustryremarks.includes("中学机构(初、高中)") ||
        //   // res.data.bodyindustryremarks == "中等职业教育机构" ||
        //   // res.data.bodyindustryremarks == "小学机构"
        //     res.data.bodyindustryremarks.includes("学校")||
        //   res.data.bodyindustryremarks.includes("高等教育机构")||
        //   res.data.bodyindustryremarks.includes("中学机构")||
        //   res.data.bodyindustryremarks.includes("小学机构")||
        //   res.data.bodyindustryremarks.includes("中等职业教育机构")
        // ) {
        //   bodyindustryremarks = "学校食堂";
        // } else if (
        //   res.data.bodyindustryremarks.includes("集体用餐") ||
        //   res.data.bodyindustryremarks.includes("中央厨房")
        // ) {
        //   bodyindustryremarks = "集体用餐配送或中央厨房";
        // } else if (res.data.bodyindustryremarks == "医院食堂") {
        //   bodyindustryremarks = "机关企事业单位食堂";
        // } else if (res.data.bodyindustryremarks == "机关单位食堂") {
        //   bodyindustryremarks = "机关企事业单位食堂";
        // } else {
        //   bodyindustryremarks = res.data.bodyindustryremarks;
        // }
        this.getBodyIndustry({
          bodyindustry: res.data.bodyindustry,
          bodyindustryremarks:res.data.bodyindustryremarks1,
          isspecialfood: res.data.isspecialfood,
        });
      });
    },
    getBodyIndustry(data) {
      findByBodyIndustry(data).then((res) => {
        if (!res.data.length) {
          setTimeout(() => {
            this.$router.push("/foodSafety/archives/archives");
          }, 2000);
          return this.$message("该单位信息暂未完善");
        }

          res.data.forEach(x => {
                if(x.moduleId=='2021003'){
                  x.moduleName='人员信息'
                }
            })
        this.list = res.data
          .filter(
            (x) => x.moduleId !== "2021001" && x.moduleId !== "2021002"&& x.moduleId !== "2021005"
            // &&x.moduleId !== "2021013"
          )
          .filter((x) => x.parentId == 0);
      if (this.data.label) {
          this.list.unshift({
            accordingRequirements:
              "依据《中华人民共和国食品安全法》规章要求实施细则;",
            bodyIndustry: "单位食堂",
            bodyIndustryId: "2021017",
            bodyIndustryRemarks: "学校食堂",
            createTime: "2021-10-19",
            frequencyNumber: 0,
            frequencyType: 6,
            functionScore: 0,
            id: "1172272220228026383",
            isSpecialFood: 0,
            isTaskItem: 0,
            moduleFullName: "责任任命",
            moduleId: "2021125",
            moduleName: "责任任命",
            moduleSort: 2,
            remark: "",
            modulePathUrl:
              "/enterprise/pages/responsibility/responsibility/responsibility",
            updateTime: "2021-10-21",
          });
          res.data.forEach(x => {
                if(x.moduleId=='2021007'){
                  x.modulePathUrl='/enterprise/pages/inspect/inspect/inspect',
                  x.moduleName='三件事'
                }
            })
        }

          if(this.data.bodyindustry=='单位食堂'||this.data.bodyindustry=='幼托机构食堂'){
       this.list.push({
          accordingRequirements:
            "依据《中华人民共和国食品安全法》规章要求实施细则;",
          bodyIndustry: "单位食堂",
          bodyIndustryId: "2021017",
          bodyIndustryRemarks: "学校食堂",
          createTime: "2021-10-19",
          frequencyNumber: 0,
          frequencyType: 6,
          functionScore: 0,
          id: "1172272220228026313",
          isSpecialFood: 0,
          isTaskItem: 0,
          moduleFullName: "食堂管理",
          moduleId: "2021169",
          moduleName: "食堂管理",
          moduleSort: 2,
          remark: "",
           modulePathUrl:
              "/enterprise/pages/canteen/canteen",
          updateTime: "2021-10-21",
        });
  }
        this.list.unshift({
          accordingRequirements:
            "依据《中华人民共和国食品安全法》规章要求实施细则;",
          bodyIndustry: "单位食堂",
          bodyIndustryId: "2021017",
          bodyIndustryRemarks: "学校食堂",
          createTime: "2021-10-19",
          frequencyNumber: 0,
          frequencyType: 6,
          functionScore: 0,
          id: "1172272220228026383",
          isSpecialFood: 0,
          isTaskItem: 0,
          moduleFullName: "综合分析",
          moduleId: "2021119",
          moduleName: "首页",
          moduleSort: 2,
          remark: "",
          modulePathUrl: "/enterprise/responsibility",
          updateTime: "2021-10-21",
        });
  
      });
    },
    menuSelect(e) {
      sessionStorage.setItem("menuSelect", e);
    },
    // Jump() {
    //   this.$router.push(
    //     sessionStorage.getItem("router") || "/foodSafety/archives/archives"
    //   );
    // },
    //     handleClick(e,event){
    // console.log(e,event);
    //     }
  },
  // 监听属性
  watch: {
    $route(to, from) {
      this.activeName = to.path;
    },
  },
  // 组件
  components: {
    "happy-scroll": HappyScroll,
  },
  // 计算属性
  computed: {},
};
</script>

<style lang="scss" scoped>
.container {
  /deep/.happy-scroll-container {
    width: 100% !important;
    height: 50px !important;
    .happy-scroll-content {
      height: 100%;
      width: 100%;
    }
  }
}
</style>